package Test06;

import java.util.ArrayList;

public class test06Test {
    public static void main(String[] args) {
        //1、创建一个集合
        ArrayList<test06> list = new ArrayList<>();

        //2、创建用户对象
        test06 user1 = new test06("001", "zhangsan", "1234567");
        test06 user2 = new test06("002", "lisi", "12345678");
        test06 user3 = new test06("003", "wangwu", "123456789");

        //3、将用户对象添加到集合当中
        list.add(user1);
        list.add(user2);
        list.add(user3);

        //4、调用方法查看id是否存在
        boolean result = contains(list, "002");

        //5、打印结果
        System.out.println(result);
    }

    //定义方法进行查找
    public static boolean contains(ArrayList<test06> list, String id) {
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).getId().equals(id)) {
                return true;
            }
        }
        return false;
    }
}
